public class JumpFloor {
    // 跳台阶
    // https://www.nowcoder.com/practice/8c82a5b80378478f9484d87d1c5f12a4?tpId=295&tqId=23261&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3DSQL%25E7%25AF%2587%26topicId%3D295
    public int jumpFloor (int number) {
        // write code here
        // dp[i] = dp[i-1] + dp[i-2]
        int[] dp = new int[number+1];
        dp[0] = dp[1] = 1;
        for (int i = 2; i <= number; i++) {
            dp[i] = dp[i-1] + dp[i-2];
        }
        return dp[number];
    }

    /**
     * 空间优化
     * @param number
     * @return
     */
    public int jumpFloor2 (int number) {
        // write code here
        // dp[i] = dp[i-1] + dp[i-2]
        int num1 = 1;
        int num2 = 1;
        for (int i = 2; i <= number; i++) {
            int tmp = num1 + num2;
            num1 = num2;
            num2 = tmp;
        }
        return num2;
    }
}
